package com.yztc.ui.details;

import com.yztc.bean.details.DetailsBean;
import com.yztc.ui.home.config.HomeUrlConfig;

/**
 * Created by My on 2016/10/10.
 */
public class DetailsPresenter implements DetailsConstact.IDetailsPresenter {
    private int productId;
    private DetailsConstact.IDetailsView detailsView;
    private DetailsModel detailsModel;
    public DetailsPresenter(DetailsConstact.IDetailsView detailsView,int productId){
        this.productId = productId;
        this.detailsView = detailsView;
        this.detailsModel = new DetailsModel();
    }
    @Override
    public void getLoadData() {
        detailsModel.toLoadData(HomeUrlConfig.Path.DETAILS_BASE_URL, productId, new DetailsModel.OnDataListener() {
            @Override
            public void successGetData(DetailsBean detailsBean) {
                detailsView.onLunBoData(detailsBean.getData().getProductImg());
                detailsView.onTitleData(detailsBean.getData().getProductInfo());
                detailsView.onGuiGeData(detailsBean.getData().getProductStyle());
                detailsView.onAnXinData(detailsBean.getData().getProductQuality());
                detailsView.onProductDetailsData(detailsBean.getData().getMstj());
                detailsView.onMyDetailsData(detailsBean.getData().getProductDetail());
                detailsView.onWxts1Data(detailsBean.getData().getWxts1());
                detailsView.onPingLunData(detailsBean.getData().getReview());
            }

            @Override
            public void failGetData(Throwable throwable) {
               detailsView.onFailLoadData(throwable);
            }
        });

    }
}
